<?php

namespace app\common\model\banxi\core;

use app\common\enums\AccountTypeEnum;
use app\common\model\common\BaseModel;
use think\model\concern\SoftDelete;

/**
 * 账户课时表
 */
class CoreAccountData extends BaseModel
{
    use SoftDelete;

    protected $name = 'banxi_core_account_data';

    protected $autoWriteTimestamp = true;

    protected $deleteTime = 'del';

    protected $defaultSoftDelete = 0;

    protected $append = [
        'accountTypeCn'
    ];
    protected $type = [
        'id' => 'string',
        'del' => 'string',
        'accountId' => 'string',
        'createTime' => 'timestamp:Y-m-d H:i:s',
        'updateTime' => 'timestamp:Y-m-d H:i:s',
    ];
    //-----------------------------------------------------------------------------------
    //-                                  获取器                                        -
    //-----------------------------------------------------------------------------------

    public function getAccountTypeCnAttr(string|null $value, array $data): string
    {
        $value = $value ?: ($data['accountType'] ?? '');
        return (new AccountTypeEnum())->getDescription($value) ?? '';
    }

    //-----------------------------------------------------------------------------------
    //-                                  处理方法                                        -
    //-----------------------------------------------------------------------------------


    //-----------------------------------------------------------------------------------
    //-                                  模型关联                                        -
    //-----------------------------------------------------------------------------------


}